home *** CD-ROM | disk | FTP | other *** search
- // SCRIPTING
- // Find duplicates in a list
-
- (***************************************************
- * Script to find duplicates in the list of *
- * selected movies. *
- * It doesn't see empty fields. *
- * *
- * (c) 2003 Louis Francisco ork@everydayangels.net *
- * *
- * For use with Ant Movie Catalog 3.4.1 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
- program FindDuplicates;
- const
- NMAX=260; //Set to the last number in the list
- var
- Titles:TStringList;
- Numbers:TStringList;
- Duplicates:TStringList;
- CurrentTitle:string;
- CurrentNumber:string;
-
- function FindTitle(title:string;list:TStringList):integer;
- var
- i:integer;
- begin
- result:=-1;
- for i:=0 to list.Count-1 do
- begin
- if list.GetString(i)=title then
- begin
- result:=i;
- break;
- end;
- end;
- end;
-
- procedure FindDuplicates();
- var
- numTitle,numDup:integer;
- begin
- numTitle:=FindTitle(CurrentTitle,Titles);
- if numTitle<>-1 then
- begin
- numDup:=FindTitle(CurrentTitle,Duplicates);
- if numDup=-1 then
- begin
- Duplicates.Text:=Duplicates.Text+
- CurrentTitle+' ('+Numbers.GetString(numTitle)
- +', '+CurrentNumber;
- end
- else
- begin
- Duplicates.SetString(numDup,
- Duplicates.GetString(numDup)+', '+CurrentNumber);
- end;
- end;
- Titles.Text:=Titles.Text+CurrentTitle;
- Numbers.Text:=Numbers.Text+CurrentNumber;
- end;
-
- procedure SaveToFile(fileName:string);
- var
- i:integer;
- begin
- for i:=0 to Duplicates.Count-1 do
- begin
- Duplicates.SetString(i,Duplicates.GetString(i)+')');
- end;
- Duplicates.SaveToFile(fileName);
- end;
-
- begin
- if CheckVersion(3,4,1) then
- begin
- if Titles=nil then
- begin
- Titles:=TStringList.Create;
- Numbers:=TStringList.Create;
- Duplicates:=TStringList.Create;
- end;
-
- CurrentTitle:=GetField(fieldOriginalTitle);
- CurrentNumber:=GetField(fieldNumber);
- // If title is empty, it generates bugs while looking to the
- // number of a duplicate movie.
- if CurrentTitle<>'' then FindDuplicates;
-
- if StrToInt(CurrentNumber,0)=NMAX then
- begin
- SaveToFile('c:\duplicates.txt');
- Titles.Free;
- Numbers.Free;
- Duplicates.Free;
- end;
- end
- else
- ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.1)');
- end.
-